{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cuda\n"
     ]
    }
   ],
   "source": [
    "from train import solver,solver2\n",
    "import torch\n",
    "from SINet.sinet import SINet\n",
    "from MyNet2.mynet2 import MyNet2\n",
    "device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n",
    "print(device)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\nSINet_model = SINet(64)\\nSINet_model.load_state_dict(torch.load(\"./model_pth/29.pth\"))\\nSI_solver = solver(SINet_model, device, epoch=30, lr=1e-4)\\n\\n# 训练\\n# SI_solver.train(\"./model_pth/\")\\n\\n# 将图片结果输出到output/目录下\\nSI_solver.test(\"./output/\")\\n'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "SINet_model = SINet(64)\n",
    "SINet_model.load_state_dict(torch.load(\"./model_pth/29.pth\"))\n",
    "SI_solver = solver(SINet_model, device, epoch=30, lr=1e-4)\n",
    "\n",
    "# 训练\n",
    "# SI_solver.train(\"./model_pth/\")\n",
    "\n",
    "# 将图片结果输出到output/目录下\n",
    "SI_solver.test(\"./output/\")\n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch:0    loss:0.6284389667851584\n",
      "Epoch:1    loss:0.39157814675143787\n",
      "Epoch:2    loss:0.2990687454917601\n",
      "Epoch:3    loss:0.23236134256635393\n",
      "Epoch:4    loss:0.20803425409165877\n",
      "Epoch:5    loss:0.18537050127184818\n",
      "Epoch:6    loss:0.16129034748034818\n",
      "Epoch:7    loss:0.1351269971073738\n",
      "Epoch:8    loss:0.11233780215893473\n",
      "Epoch:9    loss:0.16110080226723636\n",
      "Epoch:10    loss:0.16330686901829072\n",
      "Epoch:11    loss:0.1082244168408215\n",
      "Epoch:12    loss:0.08898447343547429\n",
      "Epoch:13    loss:0.08176604769591775\n",
      "Epoch:14    loss:0.078237080341205\n",
      "Epoch:15    loss:0.07991263212636113\n",
      "Epoch:16    loss:0.23871546376363506\n",
      "Epoch:17    loss:0.15798883052276713\n",
      "Epoch:18    loss:0.09842519434301981\n",
      "Epoch:19    loss:0.07892820664016263\n",
      "Epoch:20    loss:0.07649023970056858\n",
      "Epoch:21    loss:0.06695881843966033\n",
      "Epoch:22    loss:0.06624294873726155\n",
      "Epoch:23    loss:0.1357406867149153\n",
      "Epoch:24    loss:0.08429567185629691\n",
      "Epoch:25    loss:0.06458725794883712\n",
      "Epoch:26    loss:0.059491527721818004\n",
      "Epoch:27    loss:0.056761229752030753\n",
      "Epoch:28    loss:0.05578496064857713\n",
      "Epoch:29    loss:0.05645576592268688\n",
      "gen pic down\n",
      "mae:[0.06788136]\n",
      "F_measure:0.9004387259483337\n"
     ]
    }
   ],
   "source": [
    "mynet = MyNet2()\n",
    "# mynet.load_state_dict(torch.load(\"./model_pth/my/29.pth\"))\n",
    "mynet_solver = solver2(mynet, device, epoch=30, lr=1e-4)\n",
    "mynet_solver.train(\"./model_pth/my/\")\n",
    "mynet_solver.test(\"./output/my/\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\n没有RF\\nmae:[0.09475059]\\nF_measure:0.8645423650741577\\n\\n有RF\\ngen pic down\\nmae:[0.08776826]\\nF_measure:0.8626886606216431\\n\\n\\nmae:[0.07486825]\\nF_measure:0.897391676902771\\n'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 真的有用吗？ 两个loss？\n",
    "'''\n",
    "没有RF\n",
    "mae:[0.09475059]\n",
    "F_measure:0.8645423650741577\n",
    "\n",
    "有RF\n",
    "gen pic down\n",
    "mae:[0.08776826]\n",
    "F_measure:0.8626886606216431\n",
    "\n",
    "\n",
    "mae:[0.07486825]\n",
    "F_measure:0.897391676902771\n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "vir2",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
